<?php

namespace app\api\model;

use think\Model;

class OrderModel extends Model
{
    protected $name="order";
    protected $autoWriteTimestamp=true;
    protected $createTime="add_time";

    // 获取订单列表
    public function getOrderList($where,$uid)
    {
        $res = $this->where($where)->where('uid',$uid)->paginate(10);
        return msg(1,$res,'查询成功');
    }
    
    // 生成订单
    public function createOrder($goods)
    {
         $res = $this->insertGetId($goods);
         if ($res){
             return msg(1,$res,'生成订单成功');
         }else{
             return msg(0,'','生成订单失败');
         }
    }

    /**
     * 订单详情
     */
    public static function getOneOrder($order_id,$uid)
    {
        return self::where('uid',$uid)->where('id',$order_id)->find()->toArray();
    }
    
    /**
     * 根据订单号查询订单
     */

    public static function getOrderByOrderNum($order_num)
    {
        return self::where('order_num',$order_num)->find()->toArray();
    }


}
